using System;

namespace SharePoint.DataMapper
{
	/// <summary>
	/// Mapping attribute for (multi-)choice values to enum fields.
	/// </summary>
	[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
	public sealed class ChoiceAttribute : Attribute
	{
		#region Private members

		/// <summary>
		/// Name of the choice value in SharePoint.
		/// </summary>
		/// <remarks>No automatic property with private setter because of Microsoft.Design CA1019 violation.</remarks>
		private readonly string _choice;

		#endregion

		#region Constructors

		/// <summary>
		/// Creates an enum field mapping to the specified underlying SharePoint choice value.
		/// </summary>
		/// <param name="choice">SharePoint choice value where the field is mapped to.</param>
		/// <remarks>The choice value should not be XML-encoded. This will be done automatically if needed.</remarks>
		public ChoiceAttribute(string choice)
		{
			_choice = choice;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Name of the choice value in SharePoint.
		/// </summary>
		/// <remarks>The choice value should not be XML-encoded. This will be done automatically if needed.</remarks>
		public string Choice
		{
			get { return _choice; }
		}

		#endregion
	}
}